import OpenAI from "openai";

const OPENAI_API_KEY = 'sk-2qHMgOvsbppxJM11ea5oPgWtFtpViu5ghl7QlsLN8CPHdpGn'; // DEv平台的key
// openai平台key
// const OPENAI_API_KEY = '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';

const openai = new OpenAI({
  apiKey: OPENAI_API_KEY,
  baseURL: 'https://api.fe8.cn/v1',
//   baseURL: 'https://a.xairun.com/v1',
});

openai.chat.completions.create({
    // model: "gpt-4o-mini",
    model: "gpt-3.5-turbo",
    messages: [
        { role: "system", content: "你是一个AI助手" },
        {
            role: "user",
            content: "帮我写一个Python计算两个数之和的函数。",
        },
    ],
    store: true,
}).then((result) => console.log(result.choices[0].message));
